//
//  LZPlayOrPauseTableViewCell.m
//  沙哈拉FM
//
//  Created by dllo on 15/11/5.
//  Copyright © 2015年 S1mpl3. All rights reserved.
//

#import "LZPlayOrPauseTableViewCell.h"
#import "FitHeader.h"
#import "UIImage+GaussianBlur.h"
#import "LZListOrHistroyViewController.h"
#import "UIImageView+WebCache.h"
@implementation LZPlayOrPauseTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView{
    _flag = 0;
    _smallLogoImageView = [[UIImageView alloc]init];
    _smallLogoImageView.layer.cornerRadius = 25 * FITWidth;
    _smallLogoImageView.clipsToBounds = YES;
    [self.contentView addSubview:_smallLogoImageView];
    
    _nicknameLabel = [[BaseLabel alloc]init];
    _nicknameLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_nicknameLabel];
    
    _tracksLabel = [[BaseLabel alloc]init];
    _tracksLabel.font = [UIFont systemFontOfSize:13];
    _tracksLabel.alpha = .7;
    [self.contentView addSubview:_tracksLabel];
    
    _ptitleLabel = [[BaseLabel alloc]init];
    _ptitleLabel.font = _tracksLabel.font;

    [self.contentView addSubview:_ptitleLabel];
    
    _attentionButton = [BaseButton buttonWithType:UIButtonTypeCustom];
    _attentionButton.backgroundColor = [UIColor colorWithRed:0.15 green:0.57 blue:1 alpha:1];
    _attentionButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [_attentionButton setTitle:@"关注" forState:UIControlStateNormal];
    [_attentionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_attentionButton addTarget:self action:@selector(attentionAction) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_attentionButton];
    
}
#pragma mark - 关注
- (void)attentionAction{
    if (_flag == 0) {
        NSLog(@"已关注");
        [_attentionButton setTitle:@"已关注" forState:UIControlStateNormal];
        _flag = 1;
    }else{
        NSLog(@"关注");
        [_attentionButton setTitle:@"取消关注" forState:UIControlStateNormal];
        _flag = 0;
    }
}
- (void)layoutSubviews{
    [super layoutSubviews];
    _smallLogoImageView.frame = CGRectMake(10 * FITWidth, 20 * FITHeight, 50 * FITWidth, 50 * FITHeight);
    _nicknameLabel.frame = CGRectMake(_smallLogoImageView.frame.origin.x + _smallLogoImageView.frame.size.width + 10 * FITWidth, 10 * FITHeight, 200 * FITWidth, 20 * FITHeight);
    _tracksLabel.frame = CGRectMake(_nicknameLabel.frame.origin.x, _nicknameLabel.frame.origin.y + _nicknameLabel.frame.size.height, 200 * FITWidth, 20 * FITHeight);
    _ptitleLabel.frame = CGRectMake(_tracksLabel.frame.origin.x, _tracksLabel.frame.origin.y + _tracksLabel.frame.size.height, _nicknameLabel.frame.size.width, _nicknameLabel.frame.size.height);
    _attentionButton.frame = CGRectMake(_tracksLabel.frame.origin.x + _tracksLabel.frame.size.width + 30 * FITWidth, _nicknameLabel.frame.origin.y + _nicknameLabel.frame.size.height, 60 * FITWidth, 30 * FITHeight);
}
- (void)setLzBill:(LZBillboardModel *)lzBill{
    [_smallLogoImageView sd_setImageWithURL:[NSURL URLWithString:[lzBill.userInfo objectForKey:@"smallLogo"]] placeholderImage:[UIImage imageNamed:@""]];
    _nicknameLabel.text = [lzBill.userInfo objectForKey:@"nickname"];
    _tracksLabel.text = [NSString stringWithFormat:@"声音 %@   粉丝 %@", [lzBill.userInfo objectForKey:@"tracks"], [lzBill.userInfo objectForKey:@"followers"]];
    _ptitleLabel.text = [lzBill.userInfo objectForKey:@"ptitle"];
    
}
@end
